// components/questions/recordRow/recordRow.js
Component({
	properties: {
		default: {
			type: Boolean
		},
		item: {
			type: Object
		},
		key: {
			type: String
		}
	},
	data: {
		is_show: false,
		list: []
	},
	ready() {
		this.setData({ 
			is_show: this.data.default,
			rows: this.data.item,
			title: this.data.key
		})
	},
	methods: {
		handleTrigger() {
			this.setData({ is_show: !this.data.is_show })
		},
		handlePreviewImage(e) {
			var urls = e.currentTarget.dataset.urls
			var current = e.currentTarget.dataset.current
			var arr = []
			urls.forEach(item => {
				var url = encodeURI(item.replace('\n', ''))
				url = url.split('%')[0]
				arr.push(url)
			})
			this.data.list = arr
			this.data.current = current
			this.preview()
		},
		preview() {
			let current = encodeURI(this.data.current)
			current = current.split('%')[0]
			wx.previewImage({
				current: current,
				urls: this.data.list,
			})
		}
	}
})
